using System;

namespace GURUCORE.Framework.Core.Data
{
    /// <summary>
    /// mark on the class which is persistance to database
    /// </summary>
	[AttributeUsage(AttributeTargets.Class)]
	public class PersistenceClassAttribute : Attribute
	{
        #region PUBLIC PROPERTIES
        
		private string m_sTableName;
		private string m_sPKField;
		private bool m_bUpdatable;		

		public string TableName
		{
			get
			{
				return m_sTableName;
			}
			set
			{
				m_sTableName = value;
			}
		}

		public string PKField
		{
			get
			{
				return m_sPKField;
			}
			set
			{
				m_sPKField = value;
			}
		}

		public bool Updatable
		{
			get
			{
				return m_bUpdatable;
			}
			set
			{
				m_bUpdatable = value;
			}
        }

        #endregion

        #region CONSTRUCTOR
        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="p_sTableName">entity name, can be name of DB Table of DB View</param>
        /// <param name="p_sPKField">which field is primary key? can be null</param>
        /// <param name="p_bUpdatable">this entity can be update (is table)?. Set false if mark on DB View</param>
        public PersistenceClassAttribute(string p_sTableName, string p_sPKField, bool p_bUpdatable)
        {
            m_sTableName = p_sTableName;
            m_sPKField = p_sPKField;
            m_bUpdatable = p_bUpdatable;
        }

        /// <summary>
        /// G: constructor for which data can not update. Use to mark on View
        /// </summary>
        /// <param name="p_sTableName"></param>
        /// <param name="p_sPKField"></param>
        public PersistenceClassAttribute(string p_sTableName, string p_sPKField)
            : this(p_sTableName, p_sPKField, false)
        {
        }

        #endregion


    }   // end class
}   // end namespace
